package com.os.opencv.java.chapter4;

import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.highgui.HighGui;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;

public class PyrDown {

    public static void main(String[] args) {
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

        //读取图像文件并在屏幕上显示
        Mat src = Imgcodecs.imread("/Users/matt/MATT-MAC/matt_workspace/OS-OpenCV_workspace/view.jpg");
        HighGui.imshow("src", src);
        HighGui.waitKey(0);

        //对图像进行向下采样并在屏幕上显示
        Mat dst = new Mat();
        Imgproc.pyrDown(src, dst);
        HighGui.imshow("down-1", dst);
        HighGui.waitKey(0);

        //对图像进行二次向下采样并在屏幕上显示
        Imgproc.pyrDown(dst, dst);
        HighGui.imshow("down-2", dst);
        HighGui.waitKey(0);

        //将二次向下采样后的图像放大到原尺寸并在屏幕上显示
        Imgproc.resize(dst, dst, src.size());
        HighGui.imshow("resize", dst);
        HighGui.waitKey(0);

        System.exit(0);

    }
}
